package com.wisnews.controller.sec;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.wisnews.pojo.Input;
import com.wisnews.pojo.Result;
import com.wisnews.pojo.sec.entity.Role;
import com.wisnews.service.sec.Impl.RoleServiceImpl;
import com.wisnews.util.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 系统角色 前端控制器
 * </p>
 *
 * @author yuyd
 * @since 2020-12-20
 */
@RestController
@RequestMapping("/role")
public class RoleController {

    @Autowired
    private RoleServiceImpl roleService;

    @RequestMapping("getRoleInfoPage")
    public Result getRoleInfoPage(@RequestBody Input<Role> roleInput){

       IPage<Role> roleIPage = roleService.getRoleInfoPage(roleInput.toPage(),roleInput.getReq());

        return new Result(Constants.SYS_CODE.SUCCESS,Constants.SYS_CODE.SUCCESS_MESSAGE,roleIPage);
    }

    /**
     * @description: 获取所有角色信息
     * @param:
     * @return: result
     * @author yuyd
     * @date: 2021/5/2 22:01
     */
    @RequestMapping("getAllRoleInfo")
    public Result getRoleInfoPage(){

        List<Role> list = roleService.list();

        return new Result(Constants.SYS_CODE.SUCCESS,Constants.SYS_CODE.SUCCESS_MESSAGE,list);
    }

}
